// Copyright (C) 1953-2022 NUDT
// Verilog module name - packet_descriptor_discard
// Version: V4.0.0.20220526
// Created:
//         by - fenglin 
////////////////////////////////////////////////////////////////////////////
// Description:
//         
///////////////////////////////////////////////////////////////////////////

`timescale 1ns/1ps

module packet_descriptor_discard
(
        i_clk                  ,            
        i_rst_n                , 
        
        i_descriptor_wr        ,  
        iv_outportbm           , 
        iv_priority            , 
        iv_bufid               , 
        iv_flowid              , 
        iv_inport              ,
        i_discard              , 
        
        ov_priority_p0         , 
        ov_bufid_p0            , 
        ov_flowid_p0           , 
        o_descriptor_wr_p0     , 

        ov_priority_p1         , 
        ov_bufid_p1            , 
        ov_flowid_p1           , 
        o_descriptor_wr_p1     , 
       
        ov_priority_p2         , 
        ov_bufid_p2            , 
        ov_flowid_p2           , 
        o_descriptor_wr_p2     ,
       
        ov_priority_p3         , 
        ov_bufid_p3            , 
        ov_flowid_p3           , 
        o_descriptor_wr_p3     , 
       
        ov_priority_p4         , 
        ov_bufid_p4            , 
        ov_flowid_p4           , 
        o_descriptor_wr_p4     , 
        
        ov_priority_p5         , 
        ov_bufid_p5            , 
        ov_flowid_p5           , 
        o_descriptor_wr_p5     , 
      
        ov_priority_p6         , 
        ov_bufid_p6            , 
        ov_flowid_p6           , 
        o_descriptor_wr_p6     , 
        
        ov_priority_p7         , 
        ov_bufid_p7            , 
        ov_flowid_p7           , 
        o_descriptor_wr_p7     ,
        
        ov_priority_p8         ,
        ov_bufid_p8            ,
        ov_inport_p8           ,
        o_descriptor_wr_p8     ,

        ov_priority_p9           ,
        ov_bufid_p9              ,
        ov_inport_p9             ,
        o_descriptor_wr_p9       ,
        
        ov_priority_p10           ,
        ov_bufid_p10              ,
        ov_inport_p10             ,
        o_descriptor_wr_p10       ,
        
        ov_priority_p11           ,
        ov_bufid_p11              ,
        ov_inport_p11             ,
        o_descriptor_wr_p11     ,
        
        ov_priority_p12           ,
        ov_bufid_p12              ,
        ov_inport_p12             ,
        o_descriptor_wr_p12       ,
        
        ov_priority_p13           ,
        ov_bufid_p13              ,
        ov_inport_p13             ,
        o_descriptor_wr_p13       ,
        
        ov_priority_p14           ,
        ov_bufid_p14              ,
        ov_inport_p14             ,
        o_descriptor_wr_p14       ,
        
        ov_priority_p15           ,
        ov_bufid_p15              ,
        ov_inport_p15             ,
        o_descriptor_wr_p15       ,
        
        ov_priority_p16           ,
        ov_bufid_p16              ,
        ov_inport_p16             ,
        o_descriptor_wr_p16       ,
        
        ov_priority_p17           ,
        ov_bufid_p17              ,
        ov_inport_p17             ,
        o_descriptor_wr_p17       ,
        
        ov_priority_p18           ,
        ov_bufid_p18              ,
        ov_inport_p18             ,
        o_descriptor_wr_p18       ,
        
        ov_priority_p19           ,
        ov_bufid_p19              ,
        ov_inport_p19             ,
        o_descriptor_wr_p19       ,
        
        ov_priority_p20           ,
        ov_bufid_p20              ,
        ov_inport_p20             ,
        o_descriptor_wr_p20       ,
        
        ov_priority_p21           ,
        ov_bufid_p21              ,
        ov_inport_p21             ,
        o_descriptor_wr_p21       ,
        
        ov_priority_p22           ,
        ov_bufid_p22              ,
        ov_inport_p22             ,
        o_descriptor_wr_p22       ,
        
        ov_priority_p23           ,
        ov_bufid_p23              ,
        ov_inport_p23             ,
        o_descriptor_wr_p23       ,
        
        ov_priority_p24           ,
        ov_bufid_p24              ,
        ov_inport_p24             ,
        o_descriptor_wr_p24       ,
        
        ov_priority_p25           ,
        ov_bufid_p25              ,
        ov_inport_p25             ,
        o_descriptor_wr_p25       ,
        
        ov_priority_p26           ,
        ov_bufid_p26              ,
        ov_inport_p26             ,
        o_descriptor_wr_p26       ,
        
        ov_priority_p27           ,
        ov_bufid_p27              ,
        ov_inport_p27             ,
        o_descriptor_wr_p27       ,
        
        ov_priority_p28           ,
        ov_bufid_p28              ,
        ov_inport_p28             ,
        o_descriptor_wr_p28       ,
        
        ov_priority_p29           ,
        ov_bufid_p29              ,
        ov_inport_p29             ,
        o_descriptor_wr_p29       ,
        
        ov_priority_p30           ,
        ov_bufid_p30              ,
        ov_inport_p30             ,
        o_descriptor_wr_p30       ,
        
        ov_priority_p31           ,
        ov_bufid_p31              ,
        ov_inport_p31             ,
        o_descriptor_wr_p31       ,
        
        ov_priority_p32           ,//transmit to hcp.
        ov_bufid_p32              ,
        ov_inport_p32             ,
        o_descriptor_wr_p32       ,

        ov_bufid               ,   
        o_bufid_wr             , 
        i_bufid_ack            
);

// I/O
// clk & rst
input                       i_clk  ;
input                       i_rst_n;  

(*MARK_DEBUG="true"*)input                       i_descriptor_wr          ;
(*MARK_DEBUG="true"*)input           [32:0]      iv_outportbm             ;
(*MARK_DEBUG="true"*)input           [2:0]       iv_priority              ;
(*MARK_DEBUG="true"*)input           [8:0]       iv_bufid                 ;
(*MARK_DEBUG="true"*)input           [13:0]      iv_flowid                ;
(*MARK_DEBUG="true"*)input           [5:0]       iv_inport                ;
(*MARK_DEBUG="true"*)input                       i_discard                ;

output reg      [2:0]       ov_priority_p0           ;
output reg      [8:0]       ov_bufid_p0              ;
output reg      [13:0]      ov_flowid_p0             ;
output reg                  o_descriptor_wr_p0       ;
output reg      [2:0]       ov_priority_p1           ;
output reg      [8:0]       ov_bufid_p1              ;
output reg      [13:0]      ov_flowid_p1             ;
output reg                  o_descriptor_wr_p1       ;
output reg      [2:0]       ov_priority_p2           ;
output reg      [8:0]       ov_bufid_p2              ;
output reg      [13:0]      ov_flowid_p2             ;
output reg                  o_descriptor_wr_p2       ;
output reg      [2:0]       ov_priority_p3           ;
output reg      [8:0]       ov_bufid_p3              ;
output reg      [13:0]      ov_flowid_p3             ;
output reg                  o_descriptor_wr_p3       ;
output reg      [2:0]       ov_priority_p4           ;
output reg      [8:0]       ov_bufid_p4              ;
output reg      [13:0]      ov_flowid_p4             ;
output reg                  o_descriptor_wr_p4       ;
output reg      [2:0]       ov_priority_p5           ;
output reg      [8:0]       ov_bufid_p5              ;
output reg      [13:0]      ov_flowid_p5             ;
output reg                  o_descriptor_wr_p5       ;
output reg      [2:0]       ov_priority_p6           ;
output reg      [8:0]       ov_bufid_p6              ;
output reg      [13:0]      ov_flowid_p6             ;
output reg                  o_descriptor_wr_p6       ;
output reg      [2:0]       ov_priority_p7           ;
output reg      [8:0]       ov_bufid_p7              ;
output reg      [13:0]      ov_flowid_p7             ;
output reg                  o_descriptor_wr_p7       ;
output reg      [2:0]       ov_priority_p8           ;
output reg      [8:0]       ov_bufid_p8              ;
output reg      [5:0]       ov_inport_p8             ;
output reg                  o_descriptor_wr_p8       ;

output reg      [2:0]       ov_priority_p9           ;
output reg      [8:0]       ov_bufid_p9              ;
output reg      [5:0]       ov_inport_p9             ;
output reg                  o_descriptor_wr_p9       ;

output reg      [2:0]       ov_priority_p10           ;
output reg      [8:0]       ov_bufid_p10              ;
output reg      [5:0]       ov_inport_p10             ;
output reg                  o_descriptor_wr_p10       ;

output reg      [2:0]       ov_priority_p11           ;
output reg      [8:0]       ov_bufid_p11              ;
output reg      [5:0]       ov_inport_p11             ;
output reg                  o_descriptor_wr_p11       ;

output reg      [2:0]       ov_priority_p12           ;
output reg      [8:0]       ov_bufid_p12              ;
output reg      [5:0]       ov_inport_p12             ;
output reg                  o_descriptor_wr_p12       ;

output reg      [2:0]       ov_priority_p13           ;
output reg      [8:0]       ov_bufid_p13              ;
output reg      [5:0]       ov_inport_p13             ;
output reg                  o_descriptor_wr_p13       ;

output reg      [2:0]       ov_priority_p14           ;
output reg      [8:0]       ov_bufid_p14              ;
output reg      [5:0]       ov_inport_p14             ;
output reg                  o_descriptor_wr_p14       ;

output reg      [2:0]       ov_priority_p15           ;
output reg      [8:0]       ov_bufid_p15              ;
output reg      [5:0]       ov_inport_p15             ;
output reg                  o_descriptor_wr_p15       ;

(*MARK_DEBUG="true"*)output reg      [2:0]       ov_priority_p16           ;
(*MARK_DEBUG="true"*)output reg      [8:0]       ov_bufid_p16              ;
(*MARK_DEBUG="true"*)output reg      [5:0]       ov_inport_p16             ;
(*MARK_DEBUG="true"*)output reg                  o_descriptor_wr_p16       ;

(*MARK_DEBUG="true"*)output reg      [2:0]       ov_priority_p17           ;
(*MARK_DEBUG="true"*)output reg      [8:0]       ov_bufid_p17              ;
(*MARK_DEBUG="true"*)output reg      [5:0]       ov_inport_p17             ;
(*MARK_DEBUG="true"*)output reg                  o_descriptor_wr_p17       ;

output reg      [2:0]       ov_priority_p18           ;
output reg      [8:0]       ov_bufid_p18              ;
output reg      [5:0]       ov_inport_p18             ;
output reg                  o_descriptor_wr_p18       ;

output reg      [2:0]       ov_priority_p19           ;
output reg      [8:0]       ov_bufid_p19              ;
output reg      [5:0]       ov_inport_p19             ;
output reg                  o_descriptor_wr_p19       ;

output reg      [2:0]       ov_priority_p20           ;
output reg      [8:0]       ov_bufid_p20              ;
output reg      [5:0]       ov_inport_p20             ;
output reg                  o_descriptor_wr_p20       ;

output reg      [2:0]       ov_priority_p21           ;
output reg      [8:0]       ov_bufid_p21              ;
output reg      [5:0]       ov_inport_p21             ;
output reg                  o_descriptor_wr_p21       ;

output reg      [2:0]       ov_priority_p22           ;
output reg      [8:0]       ov_bufid_p22              ;
output reg      [5:0]       ov_inport_p22             ;
output reg                  o_descriptor_wr_p22       ;

output reg      [2:0]       ov_priority_p23           ;
output reg      [8:0]       ov_bufid_p23              ;
output reg      [5:0]       ov_inport_p23             ;
output reg                  o_descriptor_wr_p23       ;

output reg      [2:0]       ov_priority_p24           ;
output reg      [8:0]       ov_bufid_p24              ;
output reg      [5:0]       ov_inport_p24             ;
output reg                  o_descriptor_wr_p24       ;

output reg      [2:0]       ov_priority_p25           ;
output reg      [8:0]       ov_bufid_p25              ;
output reg      [5:0]       ov_inport_p25             ;
output reg                  o_descriptor_wr_p25       ;

output reg      [2:0]       ov_priority_p26           ;
output reg      [8:0]       ov_bufid_p26              ;
output reg      [5:0]       ov_inport_p26             ;
output reg                  o_descriptor_wr_p26       ;

output reg      [2:0]       ov_priority_p27           ;
output reg      [8:0]       ov_bufid_p27              ;
output reg      [5:0]       ov_inport_p27             ;
output reg                  o_descriptor_wr_p27       ;

output reg      [2:0]       ov_priority_p28           ;
output reg      [8:0]       ov_bufid_p28              ;
output reg      [5:0]       ov_inport_p28             ;
output reg                  o_descriptor_wr_p28       ;

output reg      [2:0]       ov_priority_p29           ;
output reg      [8:0]       ov_bufid_p29              ;
output reg      [5:0]       ov_inport_p29             ;
output reg                  o_descriptor_wr_p29       ;

output reg      [2:0]       ov_priority_p30           ;
output reg      [8:0]       ov_bufid_p30              ;
output reg      [5:0]       ov_inport_p30             ;
output reg                  o_descriptor_wr_p30       ;

output reg      [2:0]       ov_priority_p31           ;
output reg      [8:0]       ov_bufid_p31              ;
output reg      [5:0]       ov_inport_p31             ;
output reg                  o_descriptor_wr_p31       ;

output reg      [2:0]       ov_priority_p32           ;//transmit to hcp.
output reg      [8:0]       ov_bufid_p32              ;
output reg      [5:0]       ov_inport_p32             ;
output reg                  o_descriptor_wr_p32       ;

output reg      [8:0]       ov_bufid                 ;
output reg                  o_bufid_wr               ;
input                       i_bufid_ack              ;
//***************************************************
//   schedule descriptor of time-sensitive packet
//***************************************************
// internal reg&wire for state machine
reg             [8:0]       rv_fifo_wdata;
reg                         r_fifo_wr    ;          
always @(posedge i_clk or negedge i_rst_n) begin
    if(!i_rst_n) begin        
        ov_priority_p0        <= 3'b0    ;
        ov_bufid_p0           <= 9'b0    ;
        ov_flowid_p0          <= 14'b0   ;
        o_descriptor_wr_p0    <= 1'b0    ;
        ov_priority_p1        <= 3'b0    ;
        ov_bufid_p1           <= 9'b0    ;
        ov_flowid_p1          <= 14'b0   ;
        o_descriptor_wr_p1    <= 1'b0    ;
        ov_priority_p2        <= 3'b0    ;
        ov_bufid_p2           <= 9'b0    ;
        ov_flowid_p2          <= 14'b0   ;
        o_descriptor_wr_p2    <= 1'b0    ;
        ov_priority_p3        <= 3'b0    ;
        ov_bufid_p3           <= 9'b0    ;
        ov_flowid_p3          <= 14'b0   ;
        o_descriptor_wr_p3    <= 1'b0    ;
        ov_priority_p4        <= 3'b0    ;
        ov_bufid_p4           <= 9'b0    ;
        ov_flowid_p4          <= 14'b0   ;
        o_descriptor_wr_p4    <= 1'b0    ;
        ov_priority_p5        <= 3'b0    ;
        ov_bufid_p5           <= 9'b0    ;
        ov_flowid_p5          <= 14'b0   ;
        o_descriptor_wr_p5    <= 1'b0    ;
        ov_priority_p6        <= 3'b0    ;
        ov_bufid_p6           <= 9'b0    ;
        ov_flowid_p6          <= 14'b0   ;
        o_descriptor_wr_p6    <= 1'b0    ;
        ov_priority_p7        <= 3'b0    ;
        ov_bufid_p7           <= 9'b0    ;
        ov_flowid_p7          <= 14'b0   ;
        o_descriptor_wr_p7    <= 1'b0    ;        
        ov_priority_p8        <= 3'b0    ;
        ov_bufid_p8           <= 9'b0    ;
        ov_inport_p8          <= 6'b0    ;
        o_descriptor_wr_p8    <= 1'b0    ; 

        ov_priority_p9        <= 3'b0    ;
        ov_bufid_p9           <= 9'b0    ;
        ov_inport_p9          <= 6'b0    ;
        o_descriptor_wr_p9    <= 1'b0    ; 
        
        ov_priority_p10       <= 3'b0    ;
        ov_bufid_p10          <= 9'b0    ;
        ov_inport_p10         <= 6'b0    ;
        o_descriptor_wr_p10   <= 1'b0    ;
        
        ov_priority_p11       <= 3'b0    ;
        ov_bufid_p11          <= 9'b0    ;
        ov_inport_p11         <= 6'b0    ;
        o_descriptor_wr_p11   <= 1'b0    ;
        
        ov_priority_p12       <= 3'b0    ;
        ov_bufid_p12          <= 9'b0    ;
        ov_inport_p12         <= 6'b0    ;
        o_descriptor_wr_p12   <= 1'b0    ;
        
        ov_priority_p13       <= 3'b0    ;
        ov_bufid_p13          <= 9'b0    ;
        ov_inport_p13         <= 6'b0    ;
        o_descriptor_wr_p13   <= 1'b0    ;
        
        ov_priority_p14       <= 3'b0    ;
        ov_bufid_p14          <= 9'b0    ;
        ov_inport_p14         <= 6'b0    ;
        o_descriptor_wr_p14   <= 1'b0    ;
        
        ov_priority_p15       <= 3'b0    ;
        ov_bufid_p15          <= 9'b0    ;
        ov_inport_p15         <= 6'b0    ;
        o_descriptor_wr_p15   <= 1'b0    ;
        
        ov_priority_p16       <= 3'b0    ;
        ov_bufid_p16          <= 9'b0    ;
        ov_inport_p16         <= 6'b0    ;
        o_descriptor_wr_p16   <= 1'b0    ;
        
        ov_priority_p17       <= 3'b0    ;
        ov_bufid_p17          <= 9'b0    ;
        ov_inport_p17         <= 6'b0    ;
        o_descriptor_wr_p17   <= 1'b0    ;
        
        ov_priority_p18       <= 3'b0    ;
        ov_bufid_p18          <= 9'b0    ;
        ov_inport_p18         <= 6'b0    ;
        o_descriptor_wr_p18   <= 1'b0    ;
        
        ov_priority_p19       <= 3'b0    ;
        ov_bufid_p19          <= 9'b0    ;
        ov_inport_p19         <= 6'b0    ;
        o_descriptor_wr_p19   <= 1'b0    ;
        
        ov_priority_p20       <= 3'b0    ;
        ov_bufid_p20          <= 9'b0    ;
        ov_inport_p20         <= 6'b0    ;
        o_descriptor_wr_p20   <= 1'b0    ;
        
        ov_priority_p21       <= 3'b0    ;
        ov_bufid_p21          <= 9'b0    ;
        ov_inport_p21         <= 6'b0    ;
        o_descriptor_wr_p21   <= 1'b0    ;
        
        ov_priority_p22       <= 3'b0    ;
        ov_bufid_p22          <= 9'b0    ;
        ov_inport_p22         <= 6'b0    ;
        o_descriptor_wr_p22   <= 1'b0    ;
        
        ov_priority_p23       <= 3'b0    ;
        ov_bufid_p23          <= 9'b0    ;
        ov_inport_p23         <= 6'b0    ;
        o_descriptor_wr_p23   <= 1'b0    ;
        
        ov_priority_p24       <= 3'b0    ;
        ov_bufid_p24          <= 9'b0    ;
        ov_inport_p24         <= 6'b0    ;
        o_descriptor_wr_p24   <= 1'b0    ;
        
        ov_priority_p25       <= 3'b0    ;
        ov_bufid_p25          <= 9'b0    ;
        ov_inport_p25         <= 6'b0    ;
        o_descriptor_wr_p25   <= 1'b0    ;
        
        ov_priority_p26       <= 3'b0    ;
        ov_bufid_p26          <= 9'b0    ;
        ov_inport_p26         <= 6'b0    ;
        o_descriptor_wr_p26   <= 1'b0    ;
        
        ov_priority_p27       <= 3'b0    ;
        ov_bufid_p27          <= 9'b0    ;
        ov_inport_p27         <= 6'b0    ;
        o_descriptor_wr_p27   <= 1'b0    ;
        
        ov_priority_p28       <= 3'b0    ;
        ov_bufid_p28          <= 9'b0    ;
        ov_inport_p28         <= 6'b0    ;
        o_descriptor_wr_p28   <= 1'b0    ;
        
        ov_priority_p29       <= 3'b0    ;
        ov_bufid_p29          <= 9'b0    ;
        ov_inport_p29         <= 6'b0    ;
        o_descriptor_wr_p29   <= 1'b0    ;
        
        ov_priority_p30       <= 3'b0    ;
        ov_bufid_p30          <= 9'b0    ;
        ov_inport_p30         <= 6'b0    ;
        o_descriptor_wr_p30   <= 1'b0    ;
        
        ov_priority_p31       <= 3'b0    ;
        ov_bufid_p31          <= 9'b0    ;
        ov_inport_p31         <= 6'b0    ;
        o_descriptor_wr_p31   <= 1'b0    ;
        
        ov_priority_p32       <= 3'b0    ;
        ov_bufid_p32          <= 9'b0    ;
        ov_inport_p32         <= 6'b0    ;
        o_descriptor_wr_p32   <= 1'b0    ;

        rv_fifo_wdata         <= 9'b0    ;
        r_fifo_wr             <= 1'b0    ;
    end
    else begin
        if(i_descriptor_wr)begin
            if(!i_discard)begin //not discard
                rv_fifo_wdata         <= 9'b0    ;
                r_fifo_wr             <= 1'b0    ;
                if(iv_outportbm[0] == 1'b1)begin
                    ov_priority_p0        <= iv_priority    ;
                    ov_bufid_p0           <= iv_bufid       ;
                    ov_flowid_p0          <= iv_flowid      ;
                    o_descriptor_wr_p0    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p0        <= 3'b0    ;
                    ov_bufid_p0           <= 9'b0    ;
                    ov_flowid_p0          <= 14'b0   ;
                    o_descriptor_wr_p0    <= 1'b0    ;                
                end
                
                if(iv_outportbm[1] == 1'b1)begin
                    ov_priority_p1        <= iv_priority    ;
                    ov_bufid_p1           <= iv_bufid       ;
                    ov_flowid_p1          <= iv_flowid      ;
                    o_descriptor_wr_p1    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p1        <= 3'b0    ;
                    ov_bufid_p1           <= 9'b0    ;
                    ov_flowid_p1          <= 14'b0   ;
                    o_descriptor_wr_p1    <= 1'b0    ;                
                end
                
                if(iv_outportbm[2] == 1'b1)begin
                    ov_priority_p2        <= iv_priority    ;
                    ov_bufid_p2           <= iv_bufid       ;                   
                    ov_flowid_p2          <= iv_flowid      ;
                    o_descriptor_wr_p2    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p2        <= 3'b0    ;
                    ov_bufid_p2           <= 9'b0    ;
                    ov_flowid_p2          <= 14'b0   ;
                    o_descriptor_wr_p2    <= 1'b0    ;                
                end 
                
                if(iv_outportbm[3] == 1'b1)begin
                    ov_priority_p3        <= iv_priority    ;
                    ov_bufid_p3           <= iv_bufid       ;
                    ov_flowid_p3          <= iv_flowid      ;
                    o_descriptor_wr_p3    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p3        <= 3'b0    ;
                    ov_bufid_p3           <= 9'b0    ;
                    ov_flowid_p3          <= 14'b0   ;
                    o_descriptor_wr_p3    <= 1'b0    ;                
                end
                
                if(iv_outportbm[4] == 1'b1)begin
                    ov_priority_p4        <= iv_priority    ;
                    ov_bufid_p4           <= iv_bufid       ;
                    ov_flowid_p4          <= iv_flowid      ;
                    o_descriptor_wr_p4    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p4        <= 3'b0    ;
                    ov_bufid_p4           <= 9'b0    ;
                    ov_flowid_p4          <= 14'b0   ;
                    o_descriptor_wr_p4    <= 1'b0    ;                
                end  
                
                if(iv_outportbm[5] == 1'b1)begin
                    ov_priority_p5        <= iv_priority    ;
                    ov_bufid_p5           <= iv_bufid       ;
                    ov_flowid_p5          <= iv_flowid      ;
                    o_descriptor_wr_p5    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p5        <= 3'b0    ;
                    ov_bufid_p5           <= 9'b0    ;
                    ov_flowid_p5          <= 14'b0   ;
                    o_descriptor_wr_p5    <= 1'b0    ;                
                end
                
                if(iv_outportbm[6] == 1'b1)begin
                    ov_priority_p6        <= iv_priority    ;
                    ov_bufid_p6           <= iv_bufid       ;
                    ov_flowid_p6          <= iv_flowid      ;
                    o_descriptor_wr_p6    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p6        <= 3'b0    ;
                    ov_bufid_p6           <= 9'b0    ;
                    ov_flowid_p6          <= 14'b0   ;
                    o_descriptor_wr_p6    <= 1'b0    ;                
                end 
                
                if(iv_outportbm[7] == 1'b1)begin
                    ov_priority_p7        <= iv_priority    ;
                    ov_bufid_p7           <= iv_bufid       ;
                    ov_flowid_p7          <= iv_flowid      ;
                    o_descriptor_wr_p7    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p7        <= 3'b0    ;
                    ov_bufid_p7           <= 9'b0    ;
                    ov_flowid_p7          <= 14'b0   ;
                    o_descriptor_wr_p7    <= 1'b0    ;                
                end  
                
                if(iv_outportbm[8] == 1'b1)begin
                    ov_priority_p8        <= iv_priority    ;
                    ov_bufid_p8           <= iv_bufid       ;
                    ov_inport_p8          <= iv_inport      ;
                    o_descriptor_wr_p8    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p8        <= 3'b0    ;
                    ov_bufid_p8           <= 9'b0    ;
                    ov_inport_p8          <= 6'b0   ;
                    o_descriptor_wr_p8    <= 1'b0    ;                
                end

                if(iv_outportbm[9] == 1'b1)begin
                    ov_priority_p9        <= iv_priority    ;
                    ov_bufid_p9           <= iv_bufid       ;
                    ov_inport_p9          <= iv_inport      ;
                    o_descriptor_wr_p9    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p9        <= 3'b0    ;
                    ov_bufid_p9           <= 9'b0    ;
                    ov_inport_p9          <= 6'b0   ;
                    o_descriptor_wr_p9    <= 1'b0    ;                
                end 

                if(iv_outportbm[10] == 1'b1)begin
                    ov_priority_p10        <= iv_priority    ;
                    ov_bufid_p10           <= iv_bufid       ;
                    ov_inport_p10          <= iv_inport      ;
                    o_descriptor_wr_p10    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p10        <= 3'b0    ;
                    ov_bufid_p10           <= 9'b0    ;
                    ov_inport_p10          <= 6'b0   ;
                    o_descriptor_wr_p10    <= 1'b0    ;                
                end 

                if(iv_outportbm[11] == 1'b1)begin
                    ov_priority_p11        <= iv_priority    ;
                    ov_bufid_p11           <= iv_bufid       ;
                    ov_inport_p11          <= iv_inport      ;
                    o_descriptor_wr_p11    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p11        <= 3'b0    ;
                    ov_bufid_p11           <= 9'b0    ;
                    ov_inport_p11          <= 6'b0   ;
                    o_descriptor_wr_p11    <= 1'b0    ;                
                end

                if(iv_outportbm[12] == 1'b1)begin
                    ov_priority_p12        <= iv_priority    ;
                    ov_bufid_p12           <= iv_bufid       ;
                    ov_inport_p12          <= iv_inport      ;
                    o_descriptor_wr_p12    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p12        <= 3'b0    ;
                    ov_bufid_p12           <= 9'b0    ;
                    ov_inport_p12          <= 6'b0   ;
                    o_descriptor_wr_p12    <= 1'b0    ;                
                end 

                if(iv_outportbm[13] == 1'b1)begin
                    ov_priority_p13        <= iv_priority    ;
                    ov_bufid_p13           <= iv_bufid       ;
                    ov_inport_p13          <= iv_inport      ;
                    o_descriptor_wr_p13    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p13        <= 3'b0    ;
                    ov_bufid_p13           <= 9'b0    ;
                    ov_inport_p13          <= 6'b0   ;
                    o_descriptor_wr_p13    <= 1'b0    ;                
                end

                if(iv_outportbm[14] == 1'b1)begin
                    ov_priority_p14        <= iv_priority    ;
                    ov_bufid_p14           <= iv_bufid       ;
                    ov_inport_p14          <= iv_inport      ;
                    o_descriptor_wr_p14    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p14        <= 3'b0    ;
                    ov_bufid_p14           <= 9'b0    ;
                    ov_inport_p14          <= 6'b0   ;
                    o_descriptor_wr_p14    <= 1'b0    ;                
                end 

                if(iv_outportbm[15] == 1'b1)begin
                    ov_priority_p15        <= iv_priority    ;
                    ov_bufid_p15           <= iv_bufid       ;
                    ov_inport_p15          <= iv_inport      ;
                    o_descriptor_wr_p15    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p15        <= 3'b0    ;
                    ov_bufid_p15           <= 9'b0    ;
                    ov_inport_p15          <= 6'b0   ;
                    o_descriptor_wr_p15    <= 1'b0    ;                
                end 

                if(iv_outportbm[16] == 1'b1)begin
                    ov_priority_p16        <= iv_priority    ;
                    ov_bufid_p16           <= iv_bufid       ;
                    ov_inport_p16          <= iv_inport      ;
                    o_descriptor_wr_p16    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p16        <= 3'b0    ;
                    ov_bufid_p16           <= 9'b0    ;
                    ov_inport_p16          <= 6'b0   ;
                    o_descriptor_wr_p16    <= 1'b0    ;                
                end 

                if(iv_outportbm[17] == 1'b1)begin
                    ov_priority_p17        <= iv_priority    ;
                    ov_bufid_p17           <= iv_bufid       ;
                    ov_inport_p17          <= iv_inport      ;
                    o_descriptor_wr_p17    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p17        <= 3'b0    ;
                    ov_bufid_p17           <= 9'b0    ;
                    ov_inport_p17          <= 6'b0   ;
                    o_descriptor_wr_p17    <= 1'b0    ;                
                end  

                if(iv_outportbm[18] == 1'b1)begin
                    ov_priority_p18        <= iv_priority    ;
                    ov_bufid_p18           <= iv_bufid       ;
                    ov_inport_p18          <= iv_inport      ;
                    o_descriptor_wr_p18    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p18        <= 3'b0    ;
                    ov_bufid_p18           <= 9'b0    ;
                    ov_inport_p18          <= 6'b0   ;
                    o_descriptor_wr_p18    <= 1'b0    ;                
                end 

                if(iv_outportbm[19] == 1'b1)begin
                    ov_priority_p19        <= iv_priority    ;
                    ov_bufid_p19           <= iv_bufid       ;
                    ov_inport_p19          <= iv_inport      ;
                    o_descriptor_wr_p19    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p19        <= 3'b0    ;
                    ov_bufid_p19           <= 9'b0    ;
                    ov_inport_p19          <= 6'b0   ;
                    o_descriptor_wr_p19    <= 1'b0    ;                
                end  

                if(iv_outportbm[20] == 1'b1)begin
                    ov_priority_p20        <= iv_priority    ;
                    ov_bufid_p20           <= iv_bufid       ;
                    ov_inport_p20          <= iv_inport      ;
                    o_descriptor_wr_p20    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p20        <= 3'b0    ;
                    ov_bufid_p20           <= 9'b0    ;
                    ov_inport_p20          <= 6'b0   ;
                    o_descriptor_wr_p20    <= 1'b0    ;                
                end  

                if(iv_outportbm[21] == 1'b1)begin
                    ov_priority_p21        <= iv_priority    ;
                    ov_bufid_p21           <= iv_bufid       ;
                    ov_inport_p21          <= iv_inport      ;
                    o_descriptor_wr_p21    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p21        <= 3'b0    ;
                    ov_bufid_p21           <= 9'b0    ;
                    ov_inport_p21          <= 6'b0   ;
                    o_descriptor_wr_p21    <= 1'b0    ;                
                end 

                if(iv_outportbm[22] == 1'b1)begin
                    ov_priority_p22        <= iv_priority    ;
                    ov_bufid_p22           <= iv_bufid       ;
                    ov_inport_p22          <= iv_inport      ;
                    o_descriptor_wr_p22    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p22        <= 3'b0    ;
                    ov_bufid_p22           <= 9'b0    ;
                    ov_inport_p22          <= 6'b0   ;
                    o_descriptor_wr_p22    <= 1'b0    ;                
                end 

                if(iv_outportbm[23] == 1'b1)begin
                    ov_priority_p23        <= iv_priority    ;
                    ov_bufid_p23           <= iv_bufid       ;
                    ov_inport_p23          <= iv_inport      ;
                    o_descriptor_wr_p23    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p23        <= 3'b0    ;
                    ov_bufid_p23           <= 9'b0    ;
                    ov_inport_p23          <= 6'b0   ;
                    o_descriptor_wr_p23    <= 1'b0    ;                
                end     

                if(iv_outportbm[24] == 1'b1)begin
                    ov_priority_p24        <= iv_priority    ;
                    ov_bufid_p24           <= iv_bufid       ;
                    ov_inport_p24          <= iv_inport      ;
                    o_descriptor_wr_p24    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p24        <= 3'b0    ;
                    ov_bufid_p24           <= 9'b0    ;
                    ov_inport_p24          <= 6'b0   ;
                    o_descriptor_wr_p24    <= 1'b0    ;                
                end   

                if(iv_outportbm[25] == 1'b1)begin
                    ov_priority_p25        <= iv_priority    ;
                    ov_bufid_p25           <= iv_bufid       ;
                    ov_inport_p25          <= iv_inport      ;
                    o_descriptor_wr_p25    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p25        <= 3'b0    ;
                    ov_bufid_p25           <= 9'b0    ;
                    ov_inport_p25          <= 6'b0   ;
                    o_descriptor_wr_p25    <= 1'b0    ;                
                end  

                if(iv_outportbm[26] == 1'b1)begin
                    ov_priority_p26        <= iv_priority    ;
                    ov_bufid_p26           <= iv_bufid       ;
                    ov_inport_p26          <= iv_inport      ;
                    o_descriptor_wr_p26    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p26        <= 3'b0    ;
                    ov_bufid_p26           <= 9'b0    ;
                    ov_inport_p26          <= 6'b0   ;
                    o_descriptor_wr_p26    <= 1'b0    ;                
                end    

                if(iv_outportbm[27] == 1'b1)begin
                    ov_priority_p27        <= iv_priority    ;
                    ov_bufid_p27           <= iv_bufid       ;
                    ov_inport_p27          <= iv_inport      ;
                    o_descriptor_wr_p27    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p27        <= 3'b0    ;
                    ov_bufid_p27           <= 9'b0    ;
                    ov_inport_p27          <= 6'b0   ;
                    o_descriptor_wr_p27    <= 1'b0    ;                
                end  

                if(iv_outportbm[28] == 1'b1)begin
                    ov_priority_p28        <= iv_priority    ;
                    ov_bufid_p28           <= iv_bufid       ;
                    ov_inport_p28          <= iv_inport      ;
                    o_descriptor_wr_p28    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p28        <= 3'b0    ;
                    ov_bufid_p28           <= 9'b0    ;
                    ov_inport_p28          <= 6'b0   ;
                    o_descriptor_wr_p28    <= 1'b0    ;                
                end    

                if(iv_outportbm[29] == 1'b1)begin
                    ov_priority_p29        <= iv_priority    ;
                    ov_bufid_p29           <= iv_bufid       ;
                    ov_inport_p29          <= iv_inport      ;
                    o_descriptor_wr_p29    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p29        <= 3'b0    ;
                    ov_bufid_p29           <= 9'b0    ;
                    ov_inport_p29          <= 6'b0   ;
                    o_descriptor_wr_p29    <= 1'b0    ;                
                end    

                if(iv_outportbm[30] == 1'b1)begin
                    ov_priority_p30        <= iv_priority    ;
                    ov_bufid_p30           <= iv_bufid       ;
                    ov_inport_p30          <= iv_inport      ;
                    o_descriptor_wr_p30    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p30        <= 3'b0    ;
                    ov_bufid_p30           <= 9'b0    ;
                    ov_inport_p30          <= 6'b0   ;
                    o_descriptor_wr_p30    <= 1'b0    ;                
                end   

                if(iv_outportbm[31] == 1'b1)begin
                    ov_priority_p31        <= iv_priority    ;
                    ov_bufid_p31           <= iv_bufid       ;
                    ov_inport_p31          <= iv_inport      ;
                    o_descriptor_wr_p31    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p31        <= 3'b0    ;
                    ov_bufid_p31           <= 9'b0    ;
                    ov_inport_p31          <= 6'b0   ;
                    o_descriptor_wr_p31    <= 1'b0    ;                
                end   

                if(iv_outportbm[32] == 1'b1)begin//transmit to hcp.
                    ov_priority_p32        <= iv_priority    ;
                    ov_bufid_p32           <= iv_bufid       ;
                    ov_inport_p32          <= iv_inport      ;
                    o_descriptor_wr_p32    <= 1'b1           ;                
                end
                else begin
                    ov_priority_p32        <= 3'b0    ;
                    ov_bufid_p32           <= 9'b0    ;
                    ov_inport_p32          <= 6'b0   ;
                    o_descriptor_wr_p32    <= 1'b0    ;                
                end                 
            end
            else begin//discard
                rv_fifo_wdata         <= iv_bufid    ;
                r_fifo_wr             <= 1'b1        ;
                
                ov_priority_p0        <= 3'b0    ;
                ov_bufid_p0           <= 9'b0    ;
                ov_flowid_p0          <= 14'b0   ;
                o_descriptor_wr_p0    <= 1'b0    ;
                ov_priority_p1        <= 3'b0    ;
                ov_bufid_p1           <= 9'b0    ;
                ov_flowid_p1          <= 14'b0   ;
                o_descriptor_wr_p1    <= 1'b0    ;
                ov_priority_p2        <= 3'b0    ;
                ov_bufid_p2           <= 9'b0    ;
                ov_flowid_p2          <= 14'b0   ;
                o_descriptor_wr_p2    <= 1'b0    ;
                ov_priority_p3        <= 3'b0    ;
                ov_bufid_p3           <= 9'b0    ;
                ov_flowid_p3          <= 14'b0   ;
                o_descriptor_wr_p3    <= 1'b0    ;
                ov_priority_p4        <= 3'b0    ;
                ov_bufid_p4           <= 9'b0    ;
                ov_flowid_p4          <= 14'b0   ;
                o_descriptor_wr_p4    <= 1'b0    ;
                ov_priority_p5        <= 3'b0    ;
                ov_bufid_p5           <= 9'b0    ;
                ov_flowid_p5          <= 14'b0   ;
                o_descriptor_wr_p5    <= 1'b0    ;
                ov_priority_p6        <= 3'b0    ;
                ov_bufid_p6           <= 9'b0    ;
                ov_flowid_p6          <= 14'b0   ;
                o_descriptor_wr_p6    <= 1'b0    ;
                ov_priority_p7        <= 3'b0    ;
                ov_bufid_p7           <= 9'b0    ;
                ov_flowid_p7          <= 14'b0   ;
                o_descriptor_wr_p7    <= 1'b0    ;        
                ov_priority_p8        <= 3'b0    ;
                ov_bufid_p8           <= 9'b0    ;
                ov_inport_p8          <= 6'b0   ;
                o_descriptor_wr_p8    <= 1'b0    ; 

                ov_priority_p9        <= 3'b0    ;
                ov_bufid_p9           <= 9'b0    ;
                ov_inport_p9          <= 6'b0    ;
                o_descriptor_wr_p9    <= 1'b0    ; 
                
                ov_priority_p10       <= 3'b0    ;
                ov_bufid_p10          <= 9'b0    ;
                ov_inport_p10         <= 6'b0    ;
                o_descriptor_wr_p10   <= 1'b0    ;
                
                ov_priority_p11       <= 3'b0    ;
                ov_bufid_p11          <= 9'b0    ;
                ov_inport_p11         <= 6'b0    ;
                o_descriptor_wr_p11   <= 1'b0    ;
                
                ov_priority_p12       <= 3'b0    ;
                ov_bufid_p12          <= 9'b0    ;
                ov_inport_p12         <= 6'b0    ;
                o_descriptor_wr_p12   <= 1'b0    ;
                
                ov_priority_p13       <= 3'b0    ;
                ov_bufid_p13          <= 9'b0    ;
                ov_inport_p13         <= 6'b0    ;
                o_descriptor_wr_p13   <= 1'b0    ;
                
                ov_priority_p14       <= 3'b0    ;
                ov_bufid_p14          <= 9'b0    ;
                ov_inport_p14         <= 6'b0    ;
                o_descriptor_wr_p14   <= 1'b0    ;
                
                ov_priority_p15       <= 3'b0    ;
                ov_bufid_p15          <= 9'b0    ;
                ov_inport_p15         <= 6'b0    ;
                o_descriptor_wr_p15   <= 1'b0    ;
                
                ov_priority_p16       <= 3'b0    ;
                ov_bufid_p16          <= 9'b0    ;
                ov_inport_p16         <= 6'b0    ;
                o_descriptor_wr_p16   <= 1'b0    ;
                
                ov_priority_p17       <= 3'b0    ;
                ov_bufid_p17          <= 9'b0    ;
                ov_inport_p17         <= 6'b0    ;
                o_descriptor_wr_p17   <= 1'b0    ;
                
                ov_priority_p18       <= 3'b0    ;
                ov_bufid_p18          <= 9'b0    ;
                ov_inport_p18         <= 6'b0    ;
                o_descriptor_wr_p18   <= 1'b0    ;
                
                ov_priority_p19       <= 3'b0    ;
                ov_bufid_p19          <= 9'b0    ;
                ov_inport_p19         <= 6'b0    ;
                o_descriptor_wr_p19   <= 1'b0    ;
                
                ov_priority_p20       <= 3'b0    ;
                ov_bufid_p20          <= 9'b0    ;
                ov_inport_p20         <= 6'b0    ;
                o_descriptor_wr_p20   <= 1'b0    ;
                
                ov_priority_p21       <= 3'b0    ;
                ov_bufid_p21          <= 9'b0    ;
                ov_inport_p21         <= 6'b0    ;
                o_descriptor_wr_p21   <= 1'b0    ;
                
                ov_priority_p22       <= 3'b0    ;
                ov_bufid_p22          <= 9'b0    ;
                ov_inport_p22         <= 6'b0    ;
                o_descriptor_wr_p22   <= 1'b0    ;
                
                ov_priority_p23       <= 3'b0    ;
                ov_bufid_p23          <= 9'b0    ;
                ov_inport_p23         <= 6'b0    ;
                o_descriptor_wr_p23   <= 1'b0    ;
                
                ov_priority_p24       <= 3'b0    ;
                ov_bufid_p24          <= 9'b0    ;
                ov_inport_p24         <= 6'b0    ;
                o_descriptor_wr_p24   <= 1'b0    ;
                
                ov_priority_p25       <= 3'b0    ;
                ov_bufid_p25          <= 9'b0    ;
                ov_inport_p25         <= 6'b0    ;
                o_descriptor_wr_p25   <= 1'b0    ;
                
                ov_priority_p26       <= 3'b0    ;
                ov_bufid_p26          <= 9'b0    ;
                ov_inport_p26         <= 6'b0    ;
                o_descriptor_wr_p26   <= 1'b0    ;
                
                ov_priority_p27       <= 3'b0    ;
                ov_bufid_p27          <= 9'b0    ;
                ov_inport_p27         <= 6'b0    ;
                o_descriptor_wr_p27   <= 1'b0    ;
                
                ov_priority_p28       <= 3'b0    ;
                ov_bufid_p28          <= 9'b0    ;
                ov_inport_p28         <= 6'b0    ;
                o_descriptor_wr_p28   <= 1'b0    ;
                
                ov_priority_p29       <= 3'b0    ;
                ov_bufid_p29          <= 9'b0    ;
                ov_inport_p29         <= 6'b0    ;
                o_descriptor_wr_p29   <= 1'b0    ;
                
                ov_priority_p30       <= 3'b0    ;
                ov_bufid_p30          <= 9'b0    ;
                ov_inport_p30         <= 6'b0    ;
                o_descriptor_wr_p30   <= 1'b0    ;
                
                ov_priority_p31       <= 3'b0    ;
                ov_bufid_p31          <= 9'b0    ;
                ov_inport_p31         <= 6'b0    ;
                o_descriptor_wr_p31   <= 1'b0    ;
                
                ov_priority_p32       <= 3'b0    ;
                ov_bufid_p32          <= 9'b0    ;
                ov_inport_p32         <= 6'b0    ;
                o_descriptor_wr_p32   <= 1'b0    ;
                
            end
        end
        else begin//i_desp_wr is low
            rv_fifo_wdata         <= 9'b0    ;
            r_fifo_wr             <= 1'b0    ;
                        
            ov_priority_p0        <= 3'b0    ;
            ov_bufid_p0           <= 9'b0    ;
            ov_flowid_p0          <= 14'b0   ;
            o_descriptor_wr_p0    <= 1'b0    ;
            ov_priority_p1        <= 3'b0    ;
            ov_bufid_p1           <= 9'b0    ;
            ov_flowid_p1          <= 14'b0   ;
            o_descriptor_wr_p1    <= 1'b0    ;
            ov_priority_p2        <= 3'b0    ;
            ov_bufid_p2           <= 9'b0    ;
            ov_flowid_p2          <= 14'b0   ;
            o_descriptor_wr_p2    <= 1'b0    ;
            ov_priority_p3        <= 3'b0    ;
            ov_bufid_p3           <= 9'b0    ;
            ov_flowid_p3          <= 14'b0   ;
            o_descriptor_wr_p3    <= 1'b0    ;
            ov_priority_p4        <= 3'b0    ;
            ov_bufid_p4           <= 9'b0    ;
            ov_flowid_p4          <= 14'b0   ;
            o_descriptor_wr_p4    <= 1'b0    ;
            ov_priority_p5        <= 3'b0    ;
            ov_bufid_p5           <= 9'b0    ;
            ov_flowid_p5          <= 14'b0   ;
            o_descriptor_wr_p5    <= 1'b0    ;
            ov_priority_p6        <= 3'b0    ;
            ov_bufid_p6           <= 9'b0    ;
            ov_flowid_p6          <= 14'b0   ;
            o_descriptor_wr_p6    <= 1'b0    ;
            ov_priority_p7        <= 3'b0    ;
            ov_bufid_p7           <= 9'b0    ;
            ov_flowid_p7          <= 14'b0   ;
            o_descriptor_wr_p7    <= 1'b0    ;        
            ov_priority_p8        <= 3'b0    ;
            ov_bufid_p8           <= 9'b0    ;
            ov_inport_p8          <= 6'b0    ;
            o_descriptor_wr_p8    <= 1'b0    ; 

            ov_priority_p9        <= 3'b0    ;
            ov_bufid_p9           <= 9'b0    ;
            ov_inport_p9          <= 6'b0    ;
            o_descriptor_wr_p9    <= 1'b0    ; 
            
            ov_priority_p10       <= 3'b0    ;
            ov_bufid_p10          <= 9'b0    ;
            ov_inport_p10         <= 6'b0    ;
            o_descriptor_wr_p10   <= 1'b0    ;
            
            ov_priority_p11       <= 3'b0    ;
            ov_bufid_p11          <= 9'b0    ;
            ov_inport_p11         <= 6'b0    ;
            o_descriptor_wr_p11   <= 1'b0    ;
            
            ov_priority_p12       <= 3'b0    ;
            ov_bufid_p12          <= 9'b0    ;
            ov_inport_p12         <= 6'b0    ;
            o_descriptor_wr_p12   <= 1'b0    ;
            
            ov_priority_p13       <= 3'b0    ;
            ov_bufid_p13          <= 9'b0    ;
            ov_inport_p13         <= 6'b0    ;
            o_descriptor_wr_p13   <= 1'b0    ;
            
            ov_priority_p14       <= 3'b0    ;
            ov_bufid_p14          <= 9'b0    ;
            ov_inport_p14         <= 6'b0    ;
            o_descriptor_wr_p14   <= 1'b0    ;
            
            ov_priority_p15       <= 3'b0    ;
            ov_bufid_p15          <= 9'b0    ;
            ov_inport_p15         <= 6'b0    ;
            o_descriptor_wr_p15   <= 1'b0    ;
            
            ov_priority_p16       <= 3'b0    ;
            ov_bufid_p16          <= 9'b0    ;
            ov_inport_p16         <= 6'b0    ;
            o_descriptor_wr_p16   <= 1'b0    ;
            
            ov_priority_p17       <= 3'b0    ;
            ov_bufid_p17          <= 9'b0    ;
            ov_inport_p17         <= 6'b0    ;
            o_descriptor_wr_p17   <= 1'b0    ;
            
            ov_priority_p18       <= 3'b0    ;
            ov_bufid_p18          <= 9'b0    ;
            ov_inport_p18         <= 6'b0    ;
            o_descriptor_wr_p18   <= 1'b0    ;
            
            ov_priority_p19       <= 3'b0    ;
            ov_bufid_p19          <= 9'b0    ;
            ov_inport_p19         <= 6'b0    ;
            o_descriptor_wr_p19   <= 1'b0    ;
            
            ov_priority_p20       <= 3'b0    ;
            ov_bufid_p20          <= 9'b0    ;
            ov_inport_p20         <= 6'b0    ;
            o_descriptor_wr_p20   <= 1'b0    ;
            
            ov_priority_p21       <= 3'b0    ;
            ov_bufid_p21          <= 9'b0    ;
            ov_inport_p21         <= 6'b0    ;
            o_descriptor_wr_p21   <= 1'b0    ;
            
            ov_priority_p22       <= 3'b0    ;
            ov_bufid_p22          <= 9'b0    ;
            ov_inport_p22         <= 6'b0    ;
            o_descriptor_wr_p22   <= 1'b0    ;
            
            ov_priority_p23       <= 3'b0    ;
            ov_bufid_p23          <= 9'b0    ;
            ov_inport_p23         <= 6'b0    ;
            o_descriptor_wr_p23   <= 1'b0    ;
            
            ov_priority_p24       <= 3'b0    ;
            ov_bufid_p24          <= 9'b0    ;
            ov_inport_p24         <= 6'b0    ;
            o_descriptor_wr_p24   <= 1'b0    ;
            
            ov_priority_p25       <= 3'b0    ;
            ov_bufid_p25          <= 9'b0    ;
            ov_inport_p25         <= 6'b0    ;
            o_descriptor_wr_p25   <= 1'b0    ;
            
            ov_priority_p26       <= 3'b0    ;
            ov_bufid_p26          <= 9'b0    ;
            ov_inport_p26         <= 6'b0    ;
            o_descriptor_wr_p26   <= 1'b0    ;
            
            ov_priority_p27       <= 3'b0    ;
            ov_bufid_p27          <= 9'b0    ;
            ov_inport_p27         <= 6'b0    ;
            o_descriptor_wr_p27   <= 1'b0    ;
            
            ov_priority_p28       <= 3'b0    ;
            ov_bufid_p28          <= 9'b0    ;
            ov_inport_p28         <= 6'b0    ;
            o_descriptor_wr_p28   <= 1'b0    ;
            
            ov_priority_p29       <= 3'b0    ;
            ov_bufid_p29          <= 9'b0    ;
            ov_inport_p29         <= 6'b0    ;
            o_descriptor_wr_p29   <= 1'b0    ;
            
            ov_priority_p30       <= 3'b0    ;
            ov_bufid_p30          <= 9'b0    ;
            ov_inport_p30         <= 6'b0    ;
            o_descriptor_wr_p30   <= 1'b0    ;
            
            ov_priority_p31       <= 3'b0    ;
            ov_bufid_p31          <= 9'b0    ;
            ov_inport_p31         <= 6'b0    ;
            o_descriptor_wr_p31   <= 1'b0    ;
            
            ov_priority_p32       <= 3'b0    ;
            ov_bufid_p32          <= 9'b0    ;
            ov_inport_p32         <= 6'b0    ;
            o_descriptor_wr_p32   <= 1'b0    ;            
        end     
   end
end
//***************************************************
//   schedule descriptor of time-sensitive packet
//***************************************************
// internal reg&wire for state machine
wire                        w_fifo_empty_fifo2ilt      ;
reg                         r_fifo_rd_fifo2ilt         ;
wire       [8:0]            wv_fifo_rdata_fifo2ilt     ;

reg        [1:0]            bufid_state/*synthesis noprune*/;
localparam                  BUFID_IDLE_S     = 2'd0,
                            OUTPUT_BUFID_S   = 2'd1,
                            WAIT_BUFID_ACK_S = 2'd2;
always @(posedge i_clk or negedge i_rst_n)begin
    if(i_rst_n == 1'b0)begin
        r_fifo_rd_fifo2ilt     <= 1'b0    ;
    
        ov_bufid               <= 9'd0    ;
        o_bufid_wr             <= 1'b0    ;

        bufid_state            <= BUFID_IDLE_S;        
    end
    else begin
        case(bufid_state)
            BUFID_IDLE_S:begin
                if(!w_fifo_empty_fifo2ilt)begin 
                    r_fifo_rd_fifo2ilt <= 1'b1;                   
                    ov_bufid           <= 9'd0    ;
                    o_bufid_wr         <= 1'b0    ;                    
                    bufid_state        <= OUTPUT_BUFID_S;              
                end
                else begin 
                    r_fifo_rd_fifo2ilt <= 1'b0;                   
                    ov_bufid           <= 9'd0    ;
                    o_bufid_wr         <= 1'b0    ;                    
                    bufid_state        <= BUFID_IDLE_S;               
                end                
            end
            OUTPUT_BUFID_S:begin
                r_fifo_rd_fifo2ilt <= 1'b0;            
                ov_bufid           <= wv_fifo_rdata_fifo2ilt    ;
                o_bufid_wr         <= 1'b1                      ;                
                bufid_state        <= WAIT_BUFID_ACK_S;              
            end
            WAIT_BUFID_ACK_S:begin
                if(i_bufid_ack == 1'b1)begin  
                    ov_bufid           <= 9'b0        ;
                    o_bufid_wr         <= 1'b0        ;
                    bufid_state        <= BUFID_IDLE_S;    
                end
                else begin
                    bufid_state <= WAIT_BUFID_ACK_S;    
                end            
            end
            default:begin
                r_fifo_rd_fifo2ilt     <= 1'b0    ;
            
                ov_bufid               <= 9'd0    ;
                o_bufid_wr             <= 1'b0    ;

                bufid_state            <= BUFID_IDLE_S;       
            end
        endcase
    end
end   
//`ifdef altera_ip
syncfifo_showahead_aclr_w9d32 syncfifo_showahead_aclr_w9d32_pdd_inst(
	.data  (rv_fifo_wdata), 
	.wrreq (r_fifo_wr),
	.rdreq (r_fifo_rd_fifo2ilt),
	.clock (i_clk),
	.aclr  (!i_rst_n), 
	.q     (wv_fifo_rdata_fifo2ilt),    
	.usedw (),
	.full  (), 
	.empty (w_fifo_empty_fifo2ilt) 
); 
//`endif
`ifdef xilinx_ip
syncfifo_showahead_aclr_w9d32 syncfifo_showahead_aclr_w9d32_epl_inst(
.srst  (!i_rst_n),                   //Reset the all signal
.din   (rv_fifo_wdata),    //The Inport of data 
.rd_en (r_fifo_rd_fifo2ilt),       //active-high
.clk   (i_clk),                       //ASYNC WriteClk(), SYNC use wrclk
.wr_en (r_fifo_wr),       //active-high
.dout  (wv_fifo_rdata_fifo2ilt),       //The output of data
.full  (),              //Write domain full 
.empty (w_fifo_empty_fifo2ilt),                        //Write domain empty
.data_count()                         //Read-usedword
);     
`endif                  
endmodule